<html>
    <script src="strophe.js"> </script>
    <script src="jquery-1.4.2.js"> </script>
    <script src="yajschat.js" > </script>

    <script >
            //

            $(document).ready(function () { 

                   YAJSChat.bind('connected',function (event) {
                        
                        $('#to').attr('disabled',false);
                        $('#snd_msg').attr('disabled',false);
                        $('#but').attr('disabled',false);
                        $('#msg').attr('disabled',false);

                        $('#jid').attr('disabled',true);
                        $('#password').attr('disabled',true);
                        $('#login').attr('disabled',true);
        
//                        var hi = $(presence)( {}).c('show');
  //                      this.connection.send(hi);

                    
                    } );


                   YAJSChat.bind('disconnecting',function (event) {
                        $('#to').attr('disabled',true);
                        $('#snd_msg').attr('disabled',true);
                        $('#but').attr('disabled',true);
                        $('#msg').attr('disabled',true);

                        $('#jid').attr('disabled',false);
                        $('#password').attr('disabled',false);
                        $('#login').attr('disabled',false);
                  });


                YAJSChat.bind('getMessage',function (event,data) { console.log('*******************'); console.log(data);  } );
                //YAJSChat.bind('sendMessage',function (event,data) { console.log('============'); console.log(data);  } );
                YAJSChat.bind('chatStatus',function (event,data,data2) { console.log('ccccccccccccccccccccccccccccccccccc'); console.log(data2);  } );
                YAJSChat.bind('buddyStatus',function (event,data1,data2,data3) { console.log('FFFFFFFFFFFFFFFFFFFFFFF'); console.log(data1);  console.log(data3);} );

                $('#msg').live('keypress', function (ev)  {
                    if (ev.which == 13) {
                   //     ev.preventDefault();
                    }
                    else {
                        YAJSChat.setChatStatus($('#to').val(),'gone');
                        //YAJSChat.sendActivity('elahe@jabber.my','inactive');
                    }
                } );
                $('#login').click( function () {
                    YAJSChat.init( $('#jid').val() , $('#password').val() ); });



                $('#but').click( function () {
                    
                    YAJSChat.disconnect();
            
                }) ;
                $('#snd_msg').click( function () { 

                            YAJSChat.addContact("khar@jabber.my","Khar","myTest");
                    YAJSChat.sendMessage($('#to').val(),$('#msg').val() );  
                } ) ;
                
            });
    </script>
        <body>
            JID : <input type="text" value="milad@jabber.my" id="jid" /> Password : <input type="password" id="password" value="123" />
            <input type="button" id="login" value="Login" />
 <input type="button" id="but" value="Disconnect" disabled />

            <br />
            <hr />
            Send Message <br />
            To: <input type="text" id="to" value="elahe@jabber.my" disabled /> <br /> 
            Text: <br /><textarea id="msg" disabled ></textarea><br />
            <input type="button" id="snd_msg" value="Send MSG" disabled /> <br />
       <div id="log"></div>
    </body>
</html>
